<template>
  <view>
    <video id="videoPlayer" direction="0" style="width: 100vw; height: 100vh;" :src="videoUrl" controls
           @fullscreenchange="fullscreenchange" @loadedmetadata="onLoadedMetadata" :autoplay="true"></video>
  </view>
</template>

<script>
export default {
  data() {
    return {
      videoUrl: '',
      videoContext: null,
    };
  },
  onLoad(options) {
    this.videoUrl = decodeURIComponent(options.url); // 获取传递的视频URL
    this.$nextTick(() => {
      this.videoContext = uni.createVideoContext('videoPlayer');
    });
  },
  methods: {
    onLoadedMetadata() {
      this.videoContext.play(); // 播放视频
      // this.videoContext.requestFullScreen({ direction: 0 }); // 进入全屏
    },
    fullscreenchange(e) {
      // if (!e.detail.fullScreen) {
      //   uni.navigateBack(); // 如果退出全屏，则返回上一页
      // }
    },
  },
};
</script>

<style>
/* 根据需要添加样式 */
</style>
